home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7046 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.6 KB

  1. Path: lyra.csx.cam.ac.uk!gpp10
  2. From: gpp10@cus.cam.ac.uk (Giuliano Procida)
  3. Newsgroups: comp.lang.misc,comp.lang.perl.misc,comp.lang.tcl,comp.lang.c,comp.lang.java
  4. Subject: Re: Relative Speed of Perl vs. Tcl vs. C  [indentation]
  5. Date: 17 Feb 1996 19:32:34 GMT
  6. Organization: University of Cambridge, England
  7. Message-ID: <4g5agi$30g@lyra.csx.cam.ac.uk>
  8. References: <4g0bd6INNn9j@keats.ugrad.cs.ubc.ca> <4g1h0a$l72@orac.mon.rnb.com> <MARKT.96Feb16162033@atlas.harlqn.co.uk>
  9. NNTP-Posting-Host: ursa.cus.cam.ac.uk
  10.  
  11. In article <MARKT.96Feb16162033@atlas.harlqn.co.uk>,
  12. Mark Tillotson <markt@harlqn.co.uk> wrote:
  13. >hdavies@kzin.mon.rnb.com (Hugh J.E. Davies) wrote:
  14. >
  15. >> I actually like code that structures blocks by indentation, since
  16. [..]
  17. >No no no no no.  The reasons why this is a fundamentally flawed idea
  18. >are endless: linewrap, tabs, painful to automatically generate code,
  19. >virtually impossible to stream-edit code, proportional fonts,
  20. >breakable v. non-breakable spaces of differing widths, difficulty of
  21. >cut-and-paste, impossible to use yacc-style tools, difficult to read
  22. >out over the phone, hard to internationalize, sensitive to identity of
  23. >newline character, macros, statements inside expressions, ...  
  24.  
  25. If you take the view (as do Haskell etc) that "scoping via
  26. indentation" is simply an abbreviation for a more explicit syntax
  27. then most of your objections go away. Furthermore, it can arranged
  28. that any extra work needed to parse programs written this way can be
  29. done by the lexer (it just needs to insert an extra token
  30. occasionally, see Haskell report for details). If indentation is not
  31. just an abbreviation then I agree that things will be much harder with
  32. existing technology.
  33.  
  34. Linewrap: ?
  35. Tabs: lexer takes care of them
  36. Auto-generate: taken care of (indentation is an abbreviation)
  37. Stream-edit: as in sed? If so pipe it as: cat prog | unindent | sed
  38.     ... | reindent > prog1 (where unindent unabbreviates the syntax
  39.     and reindent re-abbreviates it)
  40. Proportional fonts/uneven spaces: only a problem where used
  41.     inappropriately (i.e., with a source editor that doesn't
  42.     understand them)
  43. Cut and paste: a decent source editor should take of this
  44. Yacc: can still be used (see Gofer parser, for example)
  45. Read over the phone: don't be silly, you just need to say when to pop
  46.     and push indentation, or feed it through your syntax expander and
  47.     then read it!
  48. Internationalise: ?
  49. Identity of newline: any compiler which counts lines for error
  50.     messages knows damn well what a newline looks like!
  51. Macros: (yuk) shouldn't be a problem if done post-lexer
  52. Statements inside expressions: ?
  53.  
  54. I'm not sure what you meant in some of these cases. This is just off
  55. the top of my head. I enjoy using indentation syntax; it may make
  56. source processing a little harder but that is peanuts compared to the
  57. extra clarity on-screen.
  58.  
  59. For most purposes an unindent and reindent would be the basic tools
  60. necessary. If you also have an intelligent editor which likes using
  61. proportional fonts you'll need to teach it about tabs stops as well.
  62.  
  63. >It is simply not a good idea, whitespace is too volatile to be a
  64. >syntactic marker ...
  65.  
  66. Please explain.
  67.  
  68. >... and counting spaces is too far removed from language theory.
  69.  
  70. I could say the same thing about macros :-)
  71.  
  72. I don't think indentation is as awful as you have suggested, but then
  73. I haven't met anyone in person who's tried it and really hates it.
  74. If there is a real problem (like some source manipulation algorithms
  75. become asymptotically slower) then I might change my mind.
  76.  
  77. Giuliano
  78.  
  79. ps Aren't Harlequin working on Haskell at the moment?
  80. pps Haskell Report: ftp://dcs.gla.ac.uk/pub/haskell/report/
  81.